import torch

def demo():
    #设置x,y
    x = torch.arange(12, dtype=torch.float32).reshape((3, 4))
    y = torch.tensor([[2.0, 1, 3, 4], [1, 2, 3, 4], [4, 2, 3, 1]])
    #x,y行拼接
    res1 = torch.cat((x, y), dim=0)
    # x,y列拼接
    res2 = torch.cat((x, y), dim=1)
    print(res1)
    print(res2)
    #转置
    print(y.T)
    #求均值
    print(x.mean())
    #矩阵点积
    x = torch.ones(4, dtype=torch.float32)
    print(x)
    y = torch.arange(4, dtype=torch.float32)
    print(y)
    # 矩阵点积
    print(torch.dot(x, y))
    #矩阵范数
    print(torch.norm(torch.ones(4,9)))

if __name__ == '__main__':
    demo()